home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Aug 90 / MacApp.Tech$ 8⁄31⁄90 / 1857-CopyMask while print-Aug90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  3.0 KB  |  107 lines  |  [TEXT/GEOL]

  1. Item    3724833                         29-Aug-90        01:59PDT
  2.  
  3. From:   AUST0338                        AUPtnr - Tactics Int'l,Shillito,IDV
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    CopyMask while printing
  8.  
  9. To:         MACAPP.TECH$
  10. From:       AUST0338 - David Shillito
  11. Date:       29th August 1990
  12.  
  13. Subject:    CopyMask while printing
  14.  
  15. In our application there is a need to display icons in views which are
  16. printable. Everything was working OK with the icons being displayed on the
  17. screen but when the time came to print - nothing came out. We were using
  18. CopyMask to display the icon but when I had another look at IM Page V-71 I saw
  19. the words "CopyMask doesnt send any of its drawing commands through grafProc
  20. routines; thus CopyMask calls are not recorded in pictures". After some thought
  21. I came up with the following code which seems to work OK but I can only test on
  22. the ImageWrtiter and HP PaintJet drivers. Does anyone know of any reason why
  23. this code might break on other devices such as the LaserWriter or the various
  24. color Postscript devices?
  25.  
  26. David Shillito
  27.  
  28. PROCEDURE PlotFMIcon (r: Rect; theIcon: FMIcon);
  29. VAR
  30.    iconRect: Rect;
  31.    iconMap ,
  32.    maskMap ,
  33.    dstMaskMap  : BitMap;
  34.    dstMaskRgn  : RgnHandle;
  35.    dstMaskBits : Ptr;
  36.    dstRowBytes : LONGINT;
  37. BEGIN
  38.    SetRect (iconRect, 0, 0, 32, 32);
  39.    WITH iconMap DO
  40.    BEGIN
  41.    baseAddr:= @theIcon.iconBits;
  42.    rowBytes:= 4;
  43.    bounds  := iconRect;
  44.    END;
  45.    WITH maskMap DO
  46.    BEGIN
  47.    baseAddr:= @theIcon.maskBits;
  48.    rowBytes:= 4;
  49.    bounds  := iconRect;
  50.    END;
  51.  
  52.    IF gPrinting THEN
  53.    BEGIN
  54.    dstRowBytes := (((r.right - r.left - 1) DIV 16) + 1) * 2;
  55.    dstMaskRgn  := NewRgn;
  56.    dstMaskBits := NewPtr (LONGINT(r.bottom-r.top)*dstRowBytes);
  57.    IF (dstMaskRgn <> NIL) | (dstMaskBits <> NIL) THEN
  58.    BEGIN
  59.    { scale the mask bit map to the size of the destination rectangle }
  60.    WITH dstMaskMap DO
  61.    BEGIN
  62.    baseAddr:= dstMaskBits;
  63.    rowBytes:= dstRowBytes;
  64.    bounds  := r;
  65.    END;
  66.    RGBForeColor (gRGBBlack);   { reset}
  67.    RGBBackColor (gRGBWhite);
  68.    CopyBits (maskMap, dstMaskMap, iconRect, r, srcCopy, NIL);
  69.    { convert the new mask to a region }
  70.    IF BitMapToRegion (dstMaskRgn, dstMaskMap) = noErr THEN
  71.    BEGIN
  72.    { use the region to restrict the copy into the grafport }
  73.    RGBForeColor (theIcon.foreColor);
  74.    RGBBackColor (theIcon.BackColor);
  75.    CopyBits (iconMap, thePort^.portBits, iconRect , r, srcCopy, dstMaskRgn);
  76.    END;
  77.    END;
  78.    IF dstMaskRgn <> NIL THEN
  79.    DisposeRgn (dstMaskRgn);
  80.    IF dstMaskBits <> NIL THEN
  81.    DisposPtr (dstMaskBits);
  82.    END
  83.    ELSE
  84.    BEGIN
  85.    RGBForeColor (theIcon.foreColor);
  86.    RGBBackColor (theIcon.BackColor);
  87.    CopyMask (  iconMap , maskMap   , thePort^.portBits,
  88.    iconRect, iconRect  , r);
  89.    END;
  90.    RGBForeColor (gRGBBlack);   { reset}
  91.    RGBBackColor (gRGBWhite);
  92. END {PlotFMIcon};
  93.  
  94. where
  95.  
  96.    FMIconBitsArray =   ARRAY [0..31] OF LONGINT;
  97.    FMIcon = RECORD
  98.    iconBits,
  99.    maskBits: FMIconBitsArray;
  100.    foreColor   ,
  101.    backColor   : RGBColor;
  102.    END {FMIcon};
  103.  
  104.  
  105.  
  106.  
  107.